#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <algorithm>
using namespace std;

static float Foo(int n) {
    vector<int> students;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        float tmp;
        scanf("%f", &tmp);
        const int money = (tmp * 100);
        sum += money;
        students.push_back(money);
    }

    const int mean = sum / n;
    int res = 0;
    int res2 = 0;
    for (int i = 0; i < n; ++i) {
        int diff = mean - students[i];
        if (diff > 0)
            res += diff;
        else
            res2 -= diff;
    }

    if (res2 < res)
        res = res;

    const float tmp = res / 100.0;
    return tmp;
}

int main() {
    int n = 0;
    scanf("%d", &n);
    if (n == 0)
        return 0;
    const float res = Foo(n);
    printf("$%.2f", res);

    for (;;) {
        int n = 0;
        scanf("%d", &n);
        if (n == 0)
            break;

        printf("\n");
        const float res = Foo(n);
        printf("$%.2f", res);
    }

    return 0;
}
